﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using LotteryAdmin.AdminService;
using System.Windows.Data;
using System.Reflection;
namespace LotteryAdmin
{
    public partial class ChangeBetRecord : ChildWindow
    {
        public ChangeBetRecord()
        {
            InitializeComponent();
        }
        AdminService.BetRecord record;
        AdminService.BetRecord orgRecord;
        public void ShowChildWindow(AdminService.BetRecord _record)
        {
            record = CopyValueForModel(_record);
            orgRecord = _record;
            this.dataForm1.CurrentItem = record;
            base.Show();
        }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
        AdminService.BetRecord CopyValueForModel(AdminService.BetRecord org)
        {
            AdminService.BetRecord dest = new AdminService.BetRecord();
            foreach (PropertyInfo po in org.GetType().GetProperties())
            {
                foreach (PropertyInfo pd in dest.GetType().GetProperties())
                {
                    if (pd.Name == po.Name)
                    {
                        pd.SetValue(dest, po.GetValue(org, null), null);
                        break;
                    }
                }
            }
            return dest;
        }
    }
}











